﻿Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace DotNetNuke.Modules.ActiveForums.Controls
    <DefaultProperty("Text"), ToolboxData("<{0}:ForumContentNavigator runat=server></{0}:ForumContentNavigator>")> _
    Public Class ForumContentNavigator
        Inherits WebControl
      
        Private _itemTemplate As DisplayTemplate

        Public Property ItemTemplate() As DisplayTemplate
            Get
                Return _itemTemplate
            End Get
            Set(ByVal Value As DisplayTemplate)
                _itemTemplate = Value
            End Set
        End Property
        Private _headerTemplate As DisplayTemplate
        Public Property HeaderTemplate() As DisplayTemplate
            Get
                Return _headerTemplate
            End Get
            Set(ByVal Value As DisplayTemplate)
                _headerTemplate = Value
            End Set
        End Property
        Private _footerTemplate As DisplayTemplate
        Public Property FooterTemplate() As DisplayTemplate
            Get
                Return _footerTemplate
            End Get
            Set(ByVal Value As DisplayTemplate)
                _footerTemplate = Value
            End Set
        End Property
        Public Property PortalId() As Integer = -1
        Public Property ModuleId() As Integer = -1
        Public Property TabId() As Integer = -1
        Public Property ForumId() As Integer = -1
        Public Property ForumGroupId() As Integer = -1
        Public Property ParentForumId() As Integer = -1
        Public Property IncludeClasses() As Boolean = True
        Private forumUser As User = Nothing
        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
            Dim uc As New UserController
            forumUser = uc.GetUser(PortalId, ModuleId)
            Dim fd As New Controls.ForumContent
            fd.ModuleId = ModuleId
            fd.TabId = TabId
            fd.PortalId = PortalId
            fd.ForumUser = forumUser
            fd.ForumId = ForumId
            fd.ForumGroupId = ForumGroupId
            fd.ParentForumId = ParentForumId
            fd.IncludeClasses = IncludeClasses
            If Not HttpContext.Current.Request.QueryString(ParamKeys.TopicId) Is Nothing Then
                fd.TopicId = Integer.Parse(HttpContext.Current.Request.QueryString(ParamKeys.TopicId))
            End If
            If Not ItemTemplate Is Nothing Then
                fd.ItemTemplate = ItemTemplate.Text
            End If
            If Not HeaderTemplate Is Nothing Then
                fd.HeaderTemplate = HeaderTemplate.Text
            End If
            If Not FooterTemplate Is Nothing Then
                fd.FooterTemplate = FooterTemplate.Text
            End If
            writer.Write(fd.Render())
        End Sub

    End Class

End Namespace
